<template>
  <div v-loading="loadingTable" element-loading-text="拼命加载中~" class="ticketList-box">
    <div class="ticketList-top-btn cenBet">
      <div style="width:100%;height:100%;background: #f9f9f9;  padding:16px;">
        <div class="ticketList-top-btn-left">
          <!-- <el-checkbox @change="allChangeFun" style=" margin-left: 18px;" v-model="allChange"></el-checkbox> -->
          <el-button @click="toggleGoods(0)">上架</el-button>
          <el-button @click="toggleGoods(1)">下架</el-button>
          <el-button @click="corpPrciceAlertFun()">复制价格组</el-button>
          <el-button :loading="setPriceLoding" @click="outExe()" v-if="$store.state.priceList.length">导出</el-button>
          <el-input @change="queryTicketInfoList()" style="width:220px" v-model="priceListLian" placeholder="请输入价格组链接进行搜索"></el-input>
        </div>
        <div class="ticketList-top-btn-right">
          <el-button @click="addData('add')">新建价格组</el-button>
        </div>
      </div>
    </div>
    <div v-for="(item,index) of $store.state.priceList" :key="index" class="tableList-box">
      <div class="tableList-top  ">
        <div class="tableList-top-left">
          <div style="font-size: 20px;">{{item.head.pname}} {{$moment(item.head.updateTime||item.head.createTime,'YYYY-MM-DD')}} </div>
          <div>价格组ID:{{item.head.pricegroupId}}</div>
          <div> {{item.head.vnote}}
            <el-button @click="editData('edit',item)" icon="el-icon-edit" type="text"></el-button>
          </div>
        </div>
        <div class="tableList-top-right">
          <el-button @click="resetLinkFun(item)" v-if="item.body.length&&item.head.ptype">重置链接</el-button>
          <input type="text" v-if="item.head.linkId" style=" opacity: 0;width:0px" v-model="item.head.linkId">
          <!-- v-clipboard:copy="item.head.linkId" v-clipboard:success="onCopy" v-clipboard:error="onError"  -->
          <el-button @click="copyLian(item.head.pricegroupId)" v-if="item.body.length">复制链接</el-button>
          <el-button @click="showWhoItem(item,index)">{{item.showSon?'隐藏':"更多"}}</el-button>
        </div>
      </div>
      <el-table empty-text="点击更多可查看详情~" :data="item.body" @select-all="tableSelectAll" @select="tableSelect" @selection-change="selectionChange(index)" border style="width: 100%">
        <el-table-column v-if="item.showSon" type="selection" align="center" width="55"></el-table-column>
        <el-table-column v-if="item.showSon" width="190" align="center" label="票ID票名日期" show-overflow-tooltip>
          <template slot-scope="scope">
            <div class="department-box">
              <div style="margin-right:20px">
                <el-tag size="mini" v-if="scope.row.status == 0" type="success">已上架</el-tag>
                <el-tag size="mini" v-else type="warning">已下架</el-tag>
              </div>
              <div style="text-align:left">
                <p>
                  ID:{{ scope.row.ticketId }}
                  <!-- 选中 {{scope.row.select}} -->
                </p>
                <p>
                  {{ scope.row.tname }} {{ scope.row.tTypeDate }}
                </p>
              </div>
            </div>
          </template>
        </el-table-column>
        <el-table-column v-if="item.showSon" align="center" width="300" label="地址权益">
          <template slot-scope="scope">
            <p class="cellPLeft">{{scope.row.address }}</p>
            <p class="cellPLeft">{{ scope.row.detail }}</p>
          </template>
        </el-table-column>
        <el-table-column v-if="item.showSon" prop="sprice" align="center" label="价格">
          <template slot-scope="scope">
            <p>
              {{ scope.row.sprice }}元
            </p>
          </template>
        </el-table-column>
        <el-table-column v-if="item.showSon" align="center" label="折扣价">
          <template slot-scope="scope">
            <p class="edit-menu">
              <span v-if="scope.row.eprice == null">未设置折扣价</span>
              <span v-else>{{ scope.row.eprice }}元</span>
              <span @click="discountMenu(scope.row)" class="el-icon-edit-outline" style="font-size:20px;padding-left:10px;cursor:pointer;"></span>
            </p>
          </template>
        </el-table-column>
        <el-table-column v-if="item.showSon" align="center" label="库存">
          <template slot-scope="scope">
            <p class="edit-menu">
              <span>库存 {{ scope.row.inum || 0 }}</span>
              <span @click="setInum(scope.row)" class="el-icon-edit-outline" style="font-size:20px;padding-left:10px;cursor:pointer;"></span>
            </p>
          </template>
        </el-table-column>
        <el-table-column v-if="item.showSon" align="center" label="销量">
          <template slot-scope="scope">
            <p>已卖{{ scope.row.snum || 0 }}</p>
          </template>
        </el-table-column>
        <el-table-column v-if="item.showSon" align="center" label="冻结库存">
          <template slot-scope="scope">
            <p>{{ scope.row.frozenNum || 0 }}</p>
          </template>
        </el-table-column>
        <el-table-column v-if="item.showSon" align="center" label="剩余库存">
          <template slot-scope="scope">
            <p>{{scope.row.inum-(scope.row.snum+scope.row.frozenNum)}}</p>
          </template>
        </el-table-column>
        <el-table-column v-if="item.showSon" width="160" align="center" label="发布时间">
          <template slot-scope="scope">
            <p> {{$moment(scope.row.createTime,'YYYY-MM-DD HH:mm')}} </p>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <!-- 新建价格组 -->
    <el-dialog :title="this.statusTips == 'add' ? '新建价格组' :'编辑价格组' " :visible.sync="priceAlert">
      <el-form :model="priceForm">
        <el-form-item label-width="100px" label="价格组名称">
          <el-input v-model="priceForm.name" placeholder="请输入"></el-input>
        </el-form-item>
        <el-form-item label-width="100px" label="备注">
          <el-input type="textarea" :autosize="{ minRows: 2}" v-model="priceForm.remarks" placeholder="请输入"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="priceAlert = false">取消</el-button>
        <el-button :loading="loadingAddPrice" type="primary" @click="addPriceList">确定</el-button>
      </div>
    </el-dialog>
    <!-- 复制价格组 -->
    <el-dialog title="复制价格组" :visible.sync="corpPrciceAlert">
      <el-form :model="corpPrcice">
        <el-form-item label-width="100px" label="价格组名称">
          <el-input v-model="corpPrcice.priceGroupName" placeholder="请输入"></el-input>
        </el-form-item>
        <el-form-item label-width="100px" label="是否复制库存">
          <el-select style="width:100%" v-model="corpPrcice.isCopyNum" placeholder="请选择">
            <el-option label="不复制" value="0"> </el-option>
            <el-option label="复制" value="1"> </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label-width="100px" label="备注">
          <el-input type="textarea" :autosize="{ minRows: 2}" v-model="corpPrcice.remark" placeholder="请输入"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="corpPrciceAlert = false">取消</el-button>
        <el-button :loading="loadingAddPrice" type="primary" @click="copyTicketPrciceGroupByPrciceGroupId()">确定</el-button>
      </div>
    </el-dialog>

    <!-- 设置折扣价 -->
    <el-dialog title="设置折扣价" width="600px" :visible.sync="setPriceAlert">
      <el-form :model="setPriceForm">
        <el-form-item label-width="100px" label="原价">
          <el-tag>{{ setPriceForm.sprice }}元</el-tag>
        </el-form-item>
        <el-form-item label-width="100px" label="折扣价">
          <el-slider :step="5" :max="100" :min="0" class="setPrice-item" style="width:240px; float: left;" @change="sliderChange()" v-model="setPriceFormSlider"></el-slider>
          <el-input-number class="setPrice-item" style="width:200px;margin-left: 20px; float: left;" @change="epriceCahnge()" v-model="setPriceForm.eprice" controls-position="right" :max="setPriceForm.sprice" :step="10" :min="0"></el-input-number>
        </el-form-item>
        <el-form-item label-width="100px" label="折扣标签">
          <el-input maxlength="9" v-model="setPriceForm.enote"></el-input>
        </el-form-item>
        <el-form-item label-width="100px" label="价格标签">
          <el-input maxlength="9" v-model="setPriceForm.snote"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="setPriceAlert = false">取 消</el-button>
        <el-button :loading="setPriceLoding" icon="el-icon-check" type="primary" @click="editTicket('iprise')">确 定</el-button>
      </div>
    </el-dialog>

    <!-- 设置库存 -->
    <el-dialog title="设置库存" :visible.sync="setPriceINum">
      <el-form :model="setPriceForm">
        <el-form-item label-width="100px" label="库存">
          <el-input-number style="width:100%" v-model="setPriceForm.inum" :step="100" controls-position="right" :min="0"></el-input-number>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="setPriceINum = false">取 消</el-button>
        <el-button :loading="setPriceLoding" icon="el-icon-check" type="primary" @click="editTicket('inum')">确 定</el-button>
      </div>
    </el-dialog>

    <el-dialog title="价格组链接" :visible.sync="corpAlert" width="600px">
      <span>{{corpAlertLink}}</span>
    </el-dialog>

  </div>
</template>
<script>
import GetDataFun from "./../js/GetDataFun.js"; //得到一些数据的方法
import service from "@/api/priceGroup";
import elementUIFun from "@/js/elementUIFun";
import doCopy from "do-copy";
import { getParams } from "@/components/js/decodeURIComponent";
export default {
  data() {
    return {
      priceListLian: "", //价格组链接
      corpAlertLink: "",
      corpAlert: false,
      showItem: [0], //展开某项数组
      excelData: [],
      corpPrcice: {
        priceGroupId: "",
        isCopyNum: "0",
        priceGroupName: "",
        remark: ""
      }, //价格组字段
      corpPrciceAlert: false, //复制价格组弹框
      thisTableIndex: "", //编辑当前表格的索引
      setPriceINum: false, //设置库存
      setPriceAlert: false,
      setPriceFormSlider: 0, //滑块值
      setPriceForm: {}, //设置折扣价表单
      setPriceLoding: false,
      allChange: false, //是否全选
      priceAlert: false, // 价格组的显示隐藏
      loadingAddPrice: false, // 创建时动画
      loadingTable: false, // 表格
      startDate: "",
      endDate: "",
      currentPage: 1, // 当前页数
      pageSize: 10, // 每页多少条
      statusTips: "",
      infoForm: {},
      priceForm: {
        name: "",
        remarks: ""
      } //新建价格组表单
    };
  },
  computed: {
    thisActivityId() {
      return this.$store.state.activityId;
    }
  },
  watch: {
    thisActivityId(a, b) {
      this.getTableList();
    }
  },
  created() {
    this.getTableList();
  },
  methods: {
    async queryTicketInfoList() {
      if (!this.priceListLian) {
        this.getTableList();
      } else {
        const getParamsRes = await getParams(["linkId"], this.priceListLian);
        let url = `linkId=${getParamsRes.linkId}&isPay=pay`;
        const res = await service.queryTicketInfoList(url);
        console.log(res);
        if (res.success) {
          const priceList = this.$store.state.priceList;
          for (let index = 0; index < priceList.length; index++) {
            const element = priceList[index];
            if (element.head.pricegroupId == res.data.head.pricegroupId) {
              this.$store.state.priceList = [];
              this.$store.state.priceList.push(element);
            }
          }
        }
      }
    },
    // 查询数据
    async getTableList() {
      let subData = {
        projectId: this.$store.state.activityId,
        start: 1,
        limit: 10000 //去掉分页
      };
      this.loadingTable = true;
      let { data = [] } = await service.getPriceList(subData); //价格组列表
      this.showItem = [];
      for (let i = 0; i < data.length; i++) {
        // this.allChange = false;
        data[i].showSon = false; //是否展示子选项

        // 赋值一个参数表示当前项是否被选中
        for (let j = 0; j < data[i].body.length; j++) {
          data[i].body[j].select = false;
        }

        // // // 每一项价格组详情
        // let obj = {
        //   projectId: this.$store.state.activityId,
        //   pricegroupId: data[i].head.pricegroupId
        // };
        // let deile = (await service.queryTicketPrciceGroupId(obj)).data;
        // data[i].deile = deile || [];
        if (!data[i].head.ptype) {
          // 默认价格组展开
          data[i].showSon = true;
        }
      }
      if (data.length) {
        for (let j = 0; j < this.showItem.length; j++) {
          data[this.showItem[j]].showSon = true;
        }
      }
      console.log(data);
      this.$store.state.priceList = data;
      this.loadingTable = false;
    },
    async showWhoItem(item, index) {
      if (!item.body.length) {
        const data = (await service.queryTicketPrciceGroupId({
          projectId: this.$store.state.activityId,
          pricegroupId: item.head.pricegroupId
        })).data;
        console.log(data);
        item.body = data.body;
      }

      item.showSon = !item.showSon;
      let arr = this.showItem.indexOf(index);
      if (arr >= 0) {
        this.showItem.splice(arr, 1);
      } else {
        this.showItem.push(index);
      }
      console.log(this.showItem);
    },
    // allChangeFun() {
    //   // console.log(this.allChange);
    //   console.log(this.$refs.multipleTable);
    //   if(!this.allChange){

    //   }
    // },
    // 复制链接    初始化要复制的值;
    async copyLian(pricegroupId) {
      const res = await service.getLinkByTicketPrciceGroupId({
        priceGroupId: pricegroupId
      });
      if (res.success) {
        let url = `https://${document.domain}/isv_products_pay_sell_ticket/?linkId=`;
        let text = url + res.data.linkId + "#/buyTicketHome";
        let ok = doCopy.copyHtml(text);
        if (ok) {
          this.$message({
            message: "已复制到剪贴板",
            type: "success"
          });
        } else {
          this.corpAlertLink = text;
          this.corpAlert = true;
        }
      }
    },
    // 复制价格组
    corpPrciceAlertFun() {
      let select = [];
      let priceList = this.$store.state.priceList;
      for (let i = 0; i < priceList.length; i++) {
        for (let j = 0; j < priceList[i].body.length; j++) {
          if (priceList[i].body[j].select) {
            select.push(priceList[i].body[j].pricegroupId);
          }
        }
      }
      if (!select.length) {
        this.$message({
          message: "请至少选一项",
          type: "warning"
        });
        return;
      }
      let hash = [];
      for (let i = 0; i < select.length; i++) {
        if (hash.indexOf(select[i]) == -1) {
          hash.push(select[i]);
        }
      }
      if (hash.length > 1) {
        this.$message({
          message: "只允许选择一个价格组",
          type: "warning"
        });
        return;
      }
      this.corpPrcice.priceGroupId = hash[0];
      this.corpPrciceAlert = true;
    },
    async copyTicketPrciceGroupByPrciceGroupId() {
      if (!this.corpPrcice.priceGroupName) {
        this.$message({
          message: "请输入价格组名称",
          type: "warning"
        });
        return;
      }
      let subData = {
        priceGroupId: this.corpPrcice.priceGroupId,
        activityId: this.$store.state.activityId,
        priceGroupName: this.corpPrcice.priceGroupName,
        isCopyNum: this.corpPrcice.isCopyNum,
        remark: this.corpPrcice.remark
      };
      this.loadingAddPrice = true;
      const {
        success = false
      } = await service.copyTicketPrciceGroupByPrciceGroupId(subData);
      this.loadingAddPrice = false;
      if (success) {
        this.corpPrciceAlert = false;
        this.$message({
          type: "success",
          message: "复制成功"
        });
        this.getTableList();
      }
    },
    // 当用户手动勾选数据行的 Checkbox 时触发的事件
    tableSelect(selection, row) {
      row.select = !row.select;
    },
    // 确定当前点击表格
    selectionChange(index) {
      this.thisTableIndex = index;
    },
    // 当用户手动勾选全选 Checkbox 时触发的事件
    tableSelectAll(val) {
      for (
        let i = 0;
        i < this.$store.state.priceList[this.thisTableIndex].body.length;
        i++
      ) {
        this.$store.state.priceList[this.thisTableIndex].body[i].select = false;
      }
      for (let i = 0; i < val.length; i++) {
        val[i].select = true;
      }
    },
    // 编辑价格组
    editData(statusTips, item) {
      this.statusTips = statusTips;
      this.infoForm = item;
      this.priceForm = {
        name: item.head.pname,
        remarks: item.head.vnote
      };
      this.priceAlert = true;
    },
    // 上下架   0 上架   1 下架
    async toggleGoods(item) {
      let select = [];
      let priceList = JSON.parse(JSON.stringify(this.$store.state.priceList));
      for (let i = 0; i < priceList.length; i++) {
        for (let j = 0; j < priceList[i].body.length; j++) {
          if (priceList[i].body[j].select) {
            select.push(priceList[i].body[j]);
          }
        }
      }
      if (!select.length) {
        this.$message({
          message: "请至少选一项",
          type: "warning"
        });
        return;
      }
      const confirm = await elementUIFun.$confirm(
        item == 0 ? "您确定是否要上架当前门票?" : "您确定是否要下架当前门票?"
      );
      if (!confirm) {
        return;
      }

      select.forEach(ele => {
        ele.status = item;
        console.log(ele.select);
        delete ele.select;
      });
      let subData = {
        activityId: this.$store.state.activityId,
        status: item,
        body: select
      };
      console.log(subData);
      const { success = false } = await service.updateTicketPrciceGroupStatus(
        subData
      );
      if (success) {
        this.$message({
          type: "success",
          message: item == 0 ? "门票上架成功!" : "门票下架成功!"
        });
        this.getTableList();
      }
    },
    // 提交价格组
    addPriceList() {
      if (!this.priceForm.name) {
        this.$message({
          message: "请输入价格组名称",
          type: "warning"
        });
        return;
      }
      if (!this.priceForm.remarks) {
        this.$message({
          message: "请输入备注",
          type: "warning"
        });
        return;
      }
      let url = "";
      let subData = {};
      let ptype = 1;
      if (this.$store.state.priceList.length < 1) {
        ptype = 0;
      } else {
        ptype = 1;
      }
      if (this.statusTips == "add") {
        url = "/api/isv/ticketPurchasePC/addTicketPrciceGroup";
        subData = {
          head: {
            ptype: ptype, //0表示设置为默认
            status: 0,
            projectId: this.$store.state.activityId,
            pname: this.priceForm.name,
            vnote: this.priceForm.remarks
          }
        };
      }
      if (this.statusTips == "edit") {
        url = "/api/isv/ticketPurchasePC/updateTicketPrciceGroup";
        subData = this.infoForm;
        subData.head.pname = this.priceForm.name;
        subData.head.vnote = this.priceForm.remarks;
      }

      this.$http.post(url, subData).then(
        res => {
          this.loadingAddPrice = true;
          if (res.data.success) {
            this.$message({
              message: `${
                this.statusTips == "add" ? "价格组新建成功" : "价格组编辑成功"
              }`,
              type: "success"
            });
            this.loadingAddPrice = false;
            this.priceAlert = false;
            this.priceForm = {};
            this.getTableList();
          } else {
            this.$message({
              message: res.data.errorMsg || "数据提交失败",
              type: "warning"
            });
          }
        },
        err => {
          this.loadingAddPrice = false;
          this.$message.error("服务器出小差了");
        }
      );
    },
    // 新增价格组
    addData(item) {
      this.priceForm = {};
      this.statusTips = item;
      this.priceAlert = true;
    },
    // 设置库存
    setInum(scopeRow) {
      this.setPriceForm = {
        ...scopeRow
      };
      this.setPriceINum = true;
    },
    // 设置折扣价
    discountMenu(scopeRow) {
      this.setPriceForm = {
        ...scopeRow
      };
      this.setPriceFormSlider =
        Number((scopeRow.eprice / scopeRow.sprice).toFixed(2)) * 100;
      this.setPriceAlert = true;
    }, //滑块变化
    sliderChange() {
      this.setPriceForm.eprice = (
        this.setPriceForm.sprice *
        (this.setPriceFormSlider / 100)
      ).toFixed(2);
    },
    // 折扣价
    epriceCahnge() {
      this.setPriceFormSlider =
        Number(
          (this.setPriceForm.eprice / this.setPriceForm.sprice).toFixed(2)
        ) * 100;
    },
    // 编辑折扣
    editTicket(item) {
      if (item == "iprise") {
        if (
          this.setPriceForm.eprice === "" ||
          this.setPriceForm.eprice === null
        ) {
          this.$message({
            message: "请输入折扣价",
            type: "warning"
          });
          return;
        }
        this.setPriceForm.inum = 0;
      } else {
        // if (!this.setPriceForm.inum) {
        //   this.$message({
        //     message: "请输入库存",
        //     type: "warning"
        //   });
        //   return;
        // }
      }
      let subData = JSON.parse(JSON.stringify(this.setPriceForm));
      if (!(item == "iprise")) {
        delete subData.eprice;
      }
      subData.activityId = this.$store.state.activityId;
      this.setPriceLoding = true;
      this.$http
        .post(
          "/api/isv/ticketPurchasePC/updateTicketPrciceGroupBINumAndPrice",
          subData
        )
        .then(
          res => {
            this.setPriceLoding = false;
            if (res.data.success) {
              this.$message({
                message: "修改成功",
                type: "success"
              });
              this.setPriceAlert = false;
              this.setPriceINum = false;
              this.getTableList();
            } else {
              this.$message({
                message: res.data.errorMsg || "数据提交失败",
                type: "warning"
              });
            }
          },
          err => {
            this.setPriceLoding = false;
            this.$message.error("服务器出小差了");
          }
        );
    },
    // 跳转到详情
    cellClick(row, column) {
      if (column.label == "名称") {
        this.$router.push({
          path: "/priceDetails",
          query: {
            pricegroupId: row.head.pricegroupId,
            linkId: row.head.linkId,
            status: row.head.status,
            scopeRow: row
          }
        });
      }
    },
    //  // 导出
    async outExe() {
      let dataList = [];
      let priceList = this.$store.state.priceList;
      this.setPriceLoding = true;
      for (let i = 0; i < priceList.length; i++) {
        const { data = {} } = await service.getLinkByTicketPrciceGroupId({
          priceGroupId: priceList[i].head.pricegroupId
        });
        let url = `https://${document.domain}/isv_products_pay_sell_ticket/?linkId=`;
        let text = url + data.linkId + "#/buyTicketHome";
        dataList.push({
          pname: priceList[i].head.pname,
          linkId: text
        });
      }
      this.setPriceLoding = false;
      this.excelData = dataList; //你要导出的数据list。
      this.export2Excel();
    },
    export2Excel() {
      let that = this;
      require.ensure([], () => {
        const { export_json_to_excel } = require("./../../vendor/Export2Excel"); //这里必须使用绝对路径
        const tHeader = ["价格组名称", "价格组链接"]; // 导出的表头名
        const filterVal = ["pname", "linkId"]; // 导出的表头字段名
        const list = that.excelData;
        const data = that.formatJson(filterVal, list);

        export_json_to_excel(tHeader, data, `价格组链接excel`); // 导出的表格名称，根据需要自己命名
      });
    },
    formatJson(filterVal, jsonData) {
      return jsonData.map(v => filterVal.map(j => v[j]));
    },
    // 重置链接
    resetLinkFun(item) {
      this.$confirm("您确定要重置链接, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          let subData = {
            activityId: this.$store.state.activityId,
            priceGroupId: item.head.pricegroupId,
            status: item.head.status
          };
          this.$http
            .post(
              "/api/isv/ticketPurchasePC/updateLinkStatusByPrciceGroupId",
              subData
            )
            .then(
              res => {
                if (res.data.success) {
                  this.$message({
                    type: "success",
                    message: "重置成功!"
                  });
                  this.getTableList();
                } else {
                  this.$message({
                    message: res.data.errorMsg || "重置失败",
                    type: "warning"
                  });
                }
              },
              err => {
                this.$message.error("请重试！");
              }
            );
        })
        .catch(() => {});
    },
    async handleSizeChange(val) {
      this.pageSize = val;
      this.loadingTable = true;
      await GetDataFun.getPriceList(this.currentPage, this.pageSize).then(
        res => {},
        err => {}
      );
      this.loadingTable = false;
    },
    onCopy: function() {
      this.$message({
        type: "success",
        message: "复制成功"
      });
    },
    onError: function() {
      this.$message.error("复制失败");
    },
    // 删除数据
    ticketDel(ticketD) {
      this.$confirm("您确定是否要进行删除, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          let subData = {
            activityId: ticketD.activityId,
            ticketTypeId: ticketD.ticketTypeId
          };
          this.$http.post("/api/isv/ticketType/delTicketType", subData).then(
            res => {
              if (res.data.success) {
                this.$message({
                  type: "success",
                  message: "删除成功!"
                });
                this.getTableList(this.currentPage);
              } else {
                this.$message({
                  message: res.data.errorMsg || "删除失败",
                  type: "warning"
                });
              }
            },
            err => {
              this.$message.error("服务器出小差了");
            }
          );
        })
        .catch(() => {});
    }
  }
};
</script>

<style scoped>
.ticketList-box {
  width: 100%;
  min-height: 200px;
  background: #fff;
  border-radius: 6px;
  padding: 80px 26px 16px 26px;
}
.ticketList-top-btn {
  width: 100%;
  height: auto;
  padding: 0px 50px 0px 170px;
  overflow: hidden;
  position: fixed;
  left: 0px;
  top: 100px;
  z-index: 6;
  /* background: #fff; */
  /* border: 1px solid red; */
}
.ticketList-top-btn-left {
  float: left;
  width: auto;
  height: 100%;
}
.ticketList-top-btn-right {
  float: right;
  width: auto;
  height: 100%;
}
.cellPLeft {
  text-align: left;
  width: 100%;
}
.table_content .el-table th {
  background-color: #f9f9f9 !important;
}

.tableList-box {
  width: 100%;
  height: auto;
  margin-top: 26px;
}
.tableList-top {
  width: 100%;
  height: auto;
  /* border: 1px solid red; */
  overflow: hidden;
}
.tableList-top-left {
  float: left;
  max-width: 60%;
}
.tableList-top-right {
  float: right;
  padding-top: 18px;
}
.department-box {
  padding: 0 10px;
  display: flex;
  align-items: center;
}
</style>
